package com.chagee.channel.server.controller;

import com.chagee.base.utils.HttpResponse;
import com.chagee.base.utils.HttpResponseUtil;
import com.chagee.channel.api.bo.oss.FileNameListReq;
import com.chagee.channel.server.event.service.CosService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Cos相关操作接口
 * Created by hjt 20240701
 */
@RestController
@Api(tags = "OssController", description = "Oss管理")
@RequestMapping("/qcloud/cos")
public class CosController {

    @Resource
    private CosService cosService;

    @ApiOperation(value = "cosMOV转MP4")
    @RequestMapping(value = "/toMP4File", method = RequestMethod.POST)
    @ResponseBody
    public HttpResponse<Integer> toMP4File(@RequestBody FileNameListReq fileNamelist){
        int count= cosService.toMP4(fileNamelist);
        return HttpResponseUtil.success(count);
    }
    @ApiOperation(value = "cos缓存获取转码后文件")
    @RequestMapping(value = "/getMP4File", method = RequestMethod.GET)
    @ResponseBody
    public HttpResponse<String> getMP4File(String objectName){
        String url = cosService.getMP4(objectName);
        return HttpResponseUtil.success(url);
    }
}
